<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QPicture Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QPicture Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QPicture class is a paint device that records and replays
<a href="qpainter.html">QPainter</a> commands. <a href="#details">More...</a></p>

<p>Inherits <a href="qpaintdevice.html">QPaintDevice</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qpicture.html#QPicture">__init__</a></b> (<i>self</i>, int&#160;<i>formatVersion</i>&#160;=&#160;-1)</li><li><div class="fn" /><b><a href="qpicture.html#QPicture-2">__init__</a></b> (<i>self</i>, QPicture)</li><li><div class="fn" />QRect <b><a href="qpicture.html#boundingRect">boundingRect</a></b> (<i>self</i>)</li><li><div class="fn" />str <b><a href="qpicture.html#data">data</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qpicture.html#detach">detach</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qpicture.html#devType">devType</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qpicture.html#isDetached">isDetached</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qpicture.html#isNull">isNull</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qpicture.html#load">load</a></b> (<i>self</i>, QIODevice&#160;<i>dev</i>, str&#160;<i>format</i>&#160;=&#160;None)</li><li><div class="fn" />bool <b><a href="qpicture.html#load-2">load</a></b> (<i>self</i>, QString&#160;<i>fileName</i>, str&#160;<i>format</i>&#160;=&#160;None)</li><li><div class="fn" />int <b><a href="qpicture.html#metric">metric</a></b> (<i>self</i>, QPaintDevice.PaintDeviceMetric&#160;<i>m</i>)</li><li><div class="fn" />QPaintEngine <b><a href="qpicture.html#paintEngine">paintEngine</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qpicture.html#play">play</a></b> (<i>self</i>, QPainter&#160;<i>p</i>)</li><li><div class="fn" />bool <b><a href="qpicture.html#save">save</a></b> (<i>self</i>, QIODevice&#160;<i>dev</i>, str&#160;<i>format</i>&#160;=&#160;None)</li><li><div class="fn" />bool <b><a href="qpicture.html#save-2">save</a></b> (<i>self</i>, QString&#160;<i>fileName</i>, str&#160;<i>format</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qpicture.html#setBoundingRect">setBoundingRect</a></b> (<i>self</i>, QRect&#160;<i>r</i>)</li><li><div class="fn" /><b><a href="qpicture.html#setData">setData</a></b> (<i>self</i>, str&#160;<i>data</i>)</li><li><div class="fn" />int <b><a href="qpicture.html#size">size</a></b> (<i>self</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />QStringList <b><a href="qpicture.html#inputFormatList">inputFormatList</a></b> ()</li><li><div class="fn" />list-of-QByteArray <b><a href="qpicture.html#inputFormats">inputFormats</a></b> ()</li><li><div class="fn" />QStringList <b><a href="qpicture.html#outputFormatList">outputFormatList</a></b> ()</li><li><div class="fn" />list-of-QByteArray <b><a href="qpicture.html#outputFormats">outputFormats</a></b> ()</li><li><div class="fn" />str <b><a href="qpicture.html#pictureFormat">pictureFormat</a></b> (QString&#160;<i>fileName</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QPicture class is a paint device that records and replays
<a href="qpainter.html">QPainter</a> commands.</p>
<p>A picture serializes painter commands to an IO device in a
platform-independent format. They are sometimes referred to as
meta-files.</p>
<p>Qt pictures use a proprietary binary format. Unlike native
picture (meta-file) formats on many window systems, Qt pictures
have no limitations regarding their contents. Everything that can
be painted on a widget or pixmap (e.g., fonts, pixmaps, regions,
transformed graphics, etc.) can also be stored in a picture.</p>
<p>QPicture is resolution independent, i.e. a QPicture can be
displayed on different devices (for example svg, pdf, ps, printer
and screen) looking the same. This is, for instance, needed for
WYSIWYG print preview. QPicture runs in the default system dpi, and
scales the painter to match differences in resolution depending on
the window system.</p>
<p>Example of how to record a picture:</p>
<pre class="cpp">
         <span class="type">QPicture</span> picture;
         <span class="type"><a href="qpainter.html">QPainter</a></span> painter;
         painter<span class="operator">.</span>begin(<span class="operator">&amp;</span>picture);           <span class="comment">// paint in picture</span>
         painter<span class="operator">.</span>drawEllipse(<span class="number">10</span><span class="operator">,</span><span class="number">20</span><span class="operator">,</span> <span class="number">80</span><span class="operator">,</span><span class="number">70</span>); <span class="comment">// draw an ellipse</span>
         painter<span class="operator">.</span>end();                     <span class="comment">// painting done</span>
         picture<span class="operator">.</span>save(<span class="string">"drawing.pic"</span>);       <span class="comment">// save picture</span>
</pre>
<p>Note that the list of painter commands is reset on each call to
the <a href="qpainter.html#begin">QPainter.begin</a>()
function.</p>
<p>Example of how to replay a picture:</p>
<pre class="cpp">
         <span class="type">QPicture</span> picture;
         picture<span class="operator">.</span>load(<span class="string">"drawing.pic"</span>);           <span class="comment">// load picture</span>
         <span class="type"><a href="qpainter.html">QPainter</a></span> painter;
         painter<span class="operator">.</span>begin(<span class="operator">&amp;</span>myImage);               <span class="comment">// paint in myImage</span>
         painter<span class="operator">.</span>drawPicture(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> picture);    <span class="comment">// draw the picture at (0,0)</span>
         painter<span class="operator">.</span>end();                         <span class="comment">// painting done</span>
</pre>
<p>Pictures can also be drawn using <a href="qpicture.html#play">play</a>(). Some basic data about a picture is
available, for example, <a href="qpicture.html#size">size</a>(),
<a href="qpicture.html#isNull">isNull</a>() and <a href="qpicture.html#boundingRect">boundingRect</a>().</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QPicture" />QPicture.__init__ (<i>self</i>, int&#160;<i>formatVersion</i>&#160;=&#160;-1)</h3><p>Constructs an empty picture.</p>
<p>The <i>formatVersion</i> parameter may be used to <i>create</i>
a <a href="qpicture.html">QPicture</a> that can be read by
applications that are compiled with earlier versions of Qt.</p>
<p>Note that the default formatVersion is -1 which signifies the
current release, i.e. for Qt 4.0 a formatVersion of 7 is the same
as the default formatVersion of -1.</p>
<p>Reading pictures generated by earlier versions of Qt is not
supported in Qt 4.0.</p>


<h3 class="fn"><a name="QPicture-2" />QPicture.__init__ (<i>self</i>, <a href="qpicture.html">QPicture</a>)</h3><p>Constructs a copy of <i>pic</i>.</p>
<p>This constructor is fast thanks to <a href="implicit-sharing.html">implicit sharing</a>.</p>


<h3 class="fn"><a name="boundingRect" /><a href="qrect.html">QRect</a> QPicture.boundingRect (<i>self</i>)</h3><p>Returns the picture's bounding rectangle or an invalid rectangle
if the picture contains no data.</p>
<p><b>See also</b> <a href="qpicture.html#setBoundingRect">setBoundingRect</a>().</p>


<h3 class="fn"><a name="data" />str QPicture.data (<i>self</i>)</h3><p>Returns a pointer to the picture data. The pointer is only valid
until the next non-const function is called on this picture. The
returned pointer is 0 if the picture contains no data.</p>
<p><b>See also</b> <a href="qpicture.html#setData">setData</a>(),
<a href="qpicture.html#size">size</a>(), and <a href="qpicture.html#isNull">isNull</a>().</p>


<h3 class="fn"><a name="detach" />QPicture.detach (<i>self</i>)</h3><h3 class="fn"><a name="devType" />int QPicture.devType (<i>self</i>)</h3><h3 class="fn"><a name="inputFormatList" />QStringList QPicture.inputFormatList ()</h3><h3 class="fn"><a name="inputFormats" />list-of-QByteArray QPicture.inputFormats ()</h3><h3 class="fn"><a name="isDetached" />bool QPicture.isDetached (<i>self</i>)</h3><h3 class="fn"><a name="isNull" />bool QPicture.isNull (<i>self</i>)</h3><p>Returns true if the picture contains no data; otherwise returns
false.</p>


<h3 class="fn"><a name="load" />bool QPicture.load (<i>self</i>, <a href="qiodevice.html">QIODevice</a>&#160;<i>dev</i>, str&#160;<i>format</i>&#160;=&#160;None)</h3><p>Loads a picture from the file specified by <i>fileName</i> and
returns true if successful; otherwise returns false.</p>
<p>Please note that the <i>format</i> parameter has been deprecated
and will have no effect.</p>
<p><b>See also</b> <a href="qpicture.html#save">save</a>().</p>


<h3 class="fn"><a name="load-2" />bool QPicture.load (<i>self</i>, QString&#160;<i>fileName</i>, str&#160;<i>format</i>&#160;=&#160;None)</h3><p>This is an overloaded function.</p>
<p><i>dev</i> is the device to use for loading.</p>


<h3 class="fn"><a name="metric" />int QPicture.metric (<i>self</i>, <a href="qpaintdevice.html#PaintDeviceMetric-enum">QPaintDevice.PaintDeviceMetric</a>&#160;<i>m</i>)</h3><h3 class="fn"><a name="outputFormatList" />QStringList QPicture.outputFormatList ()</h3><h3 class="fn"><a name="outputFormats" />list-of-QByteArray QPicture.outputFormats ()</h3><h3 class="fn"><a name="paintEngine" /><a href="qpaintengine.html">QPaintEngine</a> QPicture.paintEngine (<i>self</i>)</h3><h3 class="fn"><a name="pictureFormat" />str QPicture.pictureFormat (QString&#160;<i>fileName</i>)</h3><h3 class="fn"><a name="play" />bool QPicture.play (<i>self</i>, <a href="qpainter.html">QPainter</a>&#160;<i>p</i>)</h3><p>Replays the picture using <i>painter</i>, and returns true if
successful; otherwise returns false.</p>
<p>This function does exactly the same as <a href="qpainter.html#drawPicture">QPainter.drawPicture</a>() with (x, y)
= (0, 0).</p>


<h3 class="fn"><a name="save" />bool QPicture.save (<i>self</i>, <a href="qiodevice.html">QIODevice</a>&#160;<i>dev</i>, str&#160;<i>format</i>&#160;=&#160;None)</h3><p>Saves a picture to the file specified by <i>fileName</i> and
returns true if successful; otherwise returns false.</p>
<p>Please note that the <i>format</i> parameter has been deprecated
and will have no effect.</p>
<p><b>See also</b> <a href="qpicture.html#load">load</a>().</p>


<h3 class="fn"><a name="save-2" />bool QPicture.save (<i>self</i>, QString&#160;<i>fileName</i>, str&#160;<i>format</i>&#160;=&#160;None)</h3><p>This is an overloaded function.</p>
<p><i>dev</i> is the device to use for saving.</p>


<h3 class="fn"><a name="setBoundingRect" />QPicture.setBoundingRect (<i>self</i>, <a href="qrect.html">QRect</a>&#160;<i>r</i>)</h3><p>Sets the picture's bounding rectangle to <i>r</i>. The
automatically calculated value is overridden.</p>
<p><b>See also</b> <a href="qpicture.html#boundingRect">boundingRect</a>().</p>


<h3 class="fn"><a name="setData" />QPicture.setData (<i>self</i>, str&#160;<i>data</i>)</h3><p>Sets the picture data directly from <i>data</i> and <i>size</i>.
This function copies the input data.</p>
<p><b>See also</b> <a href="qpicture.html#data">data</a>() and
<a href="qpicture.html#size">size</a>().</p>


<h3 class="fn"><a name="size" />int QPicture.size (<i>self</i>)</h3><p>Returns the size of the picture data.</p>
<p><b>See also</b> <a href="qpicture.html#data">data</a>().</p>


<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.9.1 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2011</td><td align="right" width="25%">Qt&#160;4.8.0</td></tr></table></div></address></body></html>